import os
import time

name = input("请输入静态 html 路径 注意格式是utf-8.\n >").replace('"', '')

My_HTML=[]

with open(name, "r", encoding="utf-8") as f:
    My_HTML = f.readlines()


print("读取完毕.")

while True:
    key = input("请输入要查询的词(全词，不是关键字)：\n >")
    if key == "-1":
        break
    i = 0
    end = len(My_HTML)
    while True:
        if My_HTML[i].find(key) >= 0:
            print("找到，是："+My_HTML[i])
            print("上下文：")
            j = -5
            while True:
                print(My_HTML[i+j])
                j+=1
                if j == 5:
                    break
        i += 1
        if(i == end):
            break